#ifndef __ESP301_CONTROL__
#define __ESP301_CONTROL__

#include <string>
#include <serialib.h>

const int RS232_BUFFER_MAX=128;

const double ESP301_LOWER_LIMIT=0.;
const double ESP301_UPPER_LIMIT=7.;

class esp301_control {

serialib device;// object of serial device
int ret;	// return value
char buffer[RS232_BUFFER_MAX]; // buffer for temporarily containing data

bool connect();
void goHome();
void setLimit();
void chkError();
void setTolerance(float tol);

public:
double theoretical_displacement;

esp301_control();
~esp301_control();
float getPosition();
bool moveTo(double x);
bool moveBy(double dx);
void calibrate();
};

#endif
